class UnitTestDpd
  include DailyProjectDetails
  
  def initialize(document)
    @name = 'UnitTest'
    @document = document
    @data = Array.new
    parse_document
  end
  
  def parse_document
    #[1] Get the project that this dpd is associated with.
    REXML::XPath.each(@document, '/' + @name + "DailyProjectData") do |e|
      @project = "#{e.attributes['Project']}"
    end
    
    #[2] Get the UnitTest data associated with the project.
    REXML::XPath.each(@document, '/' + @name + "DailyProjectData/MemberData") do |e|
      successful_tests = "#{e.attributes['success']}"
      failed_tests = "#{e.attributes['failure']}"
      
      data = SensorData.new
      data.add_mapping('success', successful_tests)
      data.add_mapping('failure', failed_tests)
      @data.push(data)
    end
  end
  
  def get_success_count
    success_count = 0 
    for data in self.get_all_data 
      success_count += String.new(data.get_value('success')).to_i 
    end 
    return success_count
  end
  
  def get_failure_count 
    fail_count = 0
    for data in self.get_all_data 
      fail_count += String.new(data.get_value('failure')).to_i 
    end 
    return fail_count
  end
end